extends Node

var trackballCamera
	
func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	trackballCamera = $'../TrackballCamera'
	trackballCamera.mouse_enabled = true

func _input(event: InputEvent):
	if event is InputEventKey:
		var inputEvent: InputEventKey = event as InputEventKey
		if inputEvent.pressed: # 按下 KEY_ESCAPE
			if inputEvent.scancode == KEY_ESCAPE:
				Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
				trackballCamera.mouse_enabled = false
				
	if event is InputEventMouseButton:
		var clickEvent = event as InputEventMouseButton
		if clickEvent.pressed && clickEvent.button_index == BUTTON_LEFT:
				Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) 
				trackballCamera.mouse_enabled = true
